<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link th:href="@{/users/css/signin.css}" type="text/css" rel="stylesheet"/>
    <link th:href="@{/common/css/bootstrap.min.css}" type="text/css" rel="stylesheet"/>
    <script th:src="@{/common/js/jquery-1.9.1.min.js}" type="text/javascript"></script>
</head>
<body class="text-center" >
     <form method="get" class="form-signin" id="loginform">
         <img th:src="@{/users/img/head.jpg}" width="72" height="72" class="mb-4">
         <h1 class="h3 mb-3">管理员认证</h1>
         <input type="text" placeholder="请输入账号" name="anum" required class="form-control mb-3" id="anum">
         <input type="text" placeholder="请输入姓名" name="aname" required class="form-control mb-3" id="aname">
         <button type="button" class="btn btn-primary btn-lg btn-block" id="loginbtn">认证</button>
     </form>
</body>
</html>
<script>
    //jQuery获取元素使用$（'选择器'）
    //jQury实现事件绑定：$（'选择器'）.事件（function()())
    $('#loginbtn').click(function () {
        var adname = $('#adname').val();
        var adnum = $('#adnum').val();
        console.log(adnum+"////"+adname);
           $.ajax({
               url:'dologin',
               data:$('#loginform').serialize(),
               dataType:'json',
               success:function (datas) {
                   if(datas.result=="loginsuccess"){
                       alert("认证成功!");
                       location.href="index";
                   }else {
                       alert("认证失败!");
                   }
               },
               error:function () {
                   alert("通讯失败");
               }
           });

    });
</script>